package com.ihc.android.datasource;

import java.util.List;

import com.ihc.android.utilities.Constants;

import android.os.Parcel;
import android.os.Parcelable;

public class Question implements Parcelable {
	
	private long id;
	private String description;
	private GroupOfQuestions group;
	private List<Answer> answers;
	
	public Question() {
		this(0, "");
	}
	
	public Question(long id) {
		this(id, "");
	}
	
	public Question(long id, String description) {
		this.id = id;
		this.description = description;
	}
	
	public long getId() {
		return id;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public GroupOfQuestions getGroup() {
		return group;
	}
	
	public void setGroup(GroupOfQuestions group) {
		this.group = group;
	}

	public List<Answer> getAnswers() {
		return this.answers;
	}
	
	public void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}
	
	// Will be used by the ArrayAdapter in the ListView
	@Override
	public String toString() {
		return this.description;
	}

	
	public Question(Parcel source) {
		id = source.readLong();
		description = source.readString();
	}
	
	public static final Parcelable.Creator<Question> CREATOR = new Parcelable.Creator<Question>() {
        public Question createFromParcel(Parcel in) {
            return new Question(in);
        }
 
        public Question[] newArray(int size) {
            return new Question[size];
        }
    };
	
	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(id);
		dest.writeString(description);
		
	}
	
	public String toMsgBluetooth() {
		return Long.toString(this.id) + Constants.separator + this.getDescription();
	}
}
